import Home from '@/pages/Home';
import Login from '@/pages/Login';
import Register from '@/pages/Register';
import Search from '@/pages/Search';
import Deatil from '@/pages/Detail';
import AddCartSuccess from '@/pages/AddCartSuccess';
import ShopCart from '@/pages/ShopCart';
import Trade from '@/pages/Trade';
import Pay from '@/pages/Pay';
import PaySuccess from '@/pages/PaySuccess';
import Center from '@/pages/Center';

const routes = [
  {
    path: '/home',
    component: Home,
    name: 'home',
    meta: {
      isShowNav: true
    }
  },
  {
    path: '/login',
    component: Login,
    meta: {
      isShowFotter: true // 路由元信息，来添加自定义的属性存储一些信息等等
    }
  },
  {
    path: '/register',
    component: Register,
    meta: {
      isShowFotter: true
    }
  },
  {
    path: '/search/:keyword?',
    component: Search,
    name: 'search'
  },
  {
    path: '/detail/:id',
    component: Deatil,
    name: 'detail',
    props: true // 添加了这一行代码，会将之前传入的params参数直接用props来接收
  },
  {
    path: '/addcartsuccess',
    component: AddCartSuccess,
    name: 'addcartsuccess'
  },
  {
    path: '/shopcart',
    component: ShopCart,
    name: 'shopcart'
  },
  {
    // 结算界面
    path: '/trade',
    component: Trade,
    name: 'trade'
  },
  {
    // 付款界面
    path: '/pay',
    component: Pay,
    name: 'pay'
  },
  {
    // 支付成功界面
    path: '/paysuccess',
    component: PaySuccess,
    name: 'paysuccess'
  },
  {
    // 购物清单界面
    path: '/center',
    component: Center,
    name: 'center'
  },
  {
    path: '/',
    redirect: '/home' // 重定向
  }
];
export default routes;
